<template>
	<view class="uni_box home">
		<navbar title='提现'>
		</navbar>
		<view class="content">
			<view class="tione">
				<text class="tiname">提现金额</text>
				<view class="tishu">
					<u-input v-model="money" style="flex: 1;" type="text" :border="false" placeholder="请输入提现金额"/>
					<text class="qian">¥</text>
					<text class="quanbu" @click="gettixian">全部</text>
				</view>
				<!-- <u-parse class="timiao" :html="weninfo.title" :tag-style="style"></u-parse> -->
				<text class="timiao">可提现金额：{{user.money}}元  当前{{payinfo.commission}}</text>
				<!-- <text class="timiao" v-if="type==2">可提现金额：{{user.jiang}}元  当前{{payinfo.commission}}</text> -->
			</view>
			<view class="titwo">
				<text class="tiname" style="margin-bottom: 40rpx;">提现到</text>
				<view class="tilist">
					<view class="tiitem " :class="payinfo.type==item.type?'tactive':''" v-for="(item,index) in paylist" :key="index" @click="payClick(item)">
						<!-- <image class="zhiicon" v-if="item.name=='支付宝'" src="@/pages_client/static/img/icon_zfb.png" mode="" />
						<image class="zhiicon" v-if="item.name=='微信'" src="@/pages_client/static/img/icon_wx.png" mode="" />
						<image class="zhiicon" v-if="item.name=='银行卡'" src="@/pages_client/static/img/icon_yhk.png" mode="" /> -->
                        <!-- <image class="zhiicon" if :src="item.image" mode="" /> -->
						<text class="tizhitit">提现到{{ item.name }}</text>
						<image class="zhigou" src="/static/img/icon_xz_n.png" mode="" />
						<image class="zhigous" src="/static/img/icon_xz_s.png" mode="" />
					</view>
					<!-- <view class="tiitem">
						<image class="zhiicon" src="/static/img/yka.png" mode="" />
						<text class="tizhitit">提现到微信</text>
						<image class="zhigou" src="/static/img/zhigou.png" mode="" />
						<image class="zhigous" src="/static/img/zhigous.png" mode="" />
					</view> -->
					<!-- <view class="tiitem">
						<image class="zhiicon" src="/static/img/zhithree.png" mode="" />
						<text class="tizhitit">提现到微信</text>
						<image class="zhigou" src="/static/img/zhigou.png" mode="" />
						<image class="zhigous" src="/static/img/zhigous.png" mode="" />
					</view>
					<view class="tiitem">
						<image class="zhiicon" src="/static/img/zhitwo.png" mode="" />
						<text class="tizhitit">提现到银行卡</text>
						<text class="bang">去绑定</text>
						<image class="zhigou" src="/static/img/zhigou.png" mode="" />
					</view> -->
				</view>
			</view>
			<view class="tibtn" @click="getfti">去提现</view>
			<!-- <view class="ticontent">
				<u-parse :html="weninfo" :tag-style="style"></u-parse>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				money:'',
				content:'①降低服务费、拿高奖励?可以用“金币”兑换升级。点击《去升级》了解吧正常到账时间24小时。严禁套现、机刷等违规作业。疑似异常账号和订单将会延迟48-72小时处理提现，恶意违规将会冻结账号!移送公安机关!②为了避免提现失败，提现前请检查姓名、身份证和银行卡是否信息一致!如因信息错误导致提现失败，请在工作日联系客服。团队长可直接咨询你的商务导师',
				style: {
						img: 'width:max-width:100%;height:auto;pointer-events: none;'
				},
				paylist:[],
				payinfo:{},
				weninfo:'',
				tx_bfb:'',
				user:{},
                list:[],
				type:1,//收入 2奖励金 3店铺
				shop_id:''
				// cate:'shou'
			}
		},
		onLoad(option) {
			if(option.type){
				this.type = option.type
			}
			if(option.shop_id){
				this.shop_id = option.shop_id
			}
			
			// this.wenxin();
			// this.fconfiginit();
			if(this.type == 3){
				this.getusertwo()
			}else{
				this.getuser()
			}
			
		},
		onShow() {
			this.getcanshu()
		},
		methods: {
			async getuser(){
				let res = await this.$u.api.getData({
				});
				this.user = res.data

			},
			async getusertwo(){
				let res = await this.$u.api.getShopData({
					shop_id:this.shop_id
				});
				this.user = res

			},
			async fconfiginit(){
				let res = await this.$u.api.configinit({
				});
				this.tx_bfb = res.tx_bfb
			},
			async getcanshu(){
				let res = await this.$u.api.getAccountList({
				});
				this.paylist = res
				if(res){
					this.payinfo = res[0]
				}
			},
			async wenxin(){
				let res = await this.$u.api.tigetContent({
					code:'tixian'
				});
				this.weninfo = res.content
			},
			payClick(item){
				this.payinfo = item
			},
			gettixian(){
				// if(this.type == 1){
				// 	//收入
					
				// }else if(this.type == 2){
				// 	this.money = this.user.jiang
				// }
				this.money = this.user.money
				
			},
			getaccount(){
				this.navrouter("/pages_client/twoPage/M-AccountManage");
			},
			async getfti(){
				if(!this.money){
					this.$u.toast("请输入金额");
					return false
				}
				if(Number(this.money)<Number(1)){
					this.$u.toast("提现金额最少为1元");
					return false
				}
				if(this.payinfo.account == ''){
					this.$u.toast("请先绑定账号");
					let that = this
					setTimeout(() => {
						that.getaccount()
					}, 1500);
					return false
				}
				if(this.type == 3){
					//店铺
					let res = await this.$u.api.addWithdrawal({
						money:Number(this.money),
						type:this.payinfo.type,
						cate:'money',
						shop_id:this.shop_id
					});
					console.log(res)
					this.$u.toast("操作成功");
					this.money = ''
					this.getusertwo()
				}else{
					let res = await this.$u.api.tiaddOrder({
						money:Number(this.money),
						type:this.payinfo.type,
						cate:this.type==1?'shou':'jiang'
					});
					console.log(res)
					this.$u.toast("操作成功");
					this.money = ''
					this.getuser()
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #fff;
	}
	.content{
		min-height: 100vh;
		background-color: #f5f5f5;
		padding: 20rpx 30rpx;
		.tione{
			padding: 30rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			
			.tishu{
				background: #F5F5F5;
				border-radius: 20rpx;
				padding: 20rpx;
				display: flex;
				flex-direction: row;
				margin: 20rpx 0;
				align-items: center;
				.quanbu{
					display: inline-block;
					margin-left: 8rpx;
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 32rpx;
					color: #52443B;
					margin-left: 15rpx;
				}
				.qian{
					display: inline-block;
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 36rpx;
					color: #333333;
				}
			}
			.timiao{
				font-family: Adobe Heiti Std;
				font-weight: normal;
				font-size: 28rpx;
				color: #999999;
			}
		}
		.tiname{
			font-family: PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #51565D;
			display: block;
		}
		.titwo{
			padding: 30rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin: 30rpx 0;
			.tilist{
				display: flex;
				flex-direction: column;
				.tiitem{
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-bottom: 40rpx;
					.zhiicon{
						width: 60rpx;
						height: 60rpx;
						margin-right: 20rpx;
					}
					.tizhitit{
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #333333;
					}
					.zhigou{
						margin-left: auto;
						width: 48rpx;
						height: 48rpx;
					}
					.zhigous{
						margin-left: auto;
						width: 48rpx;
						height: 48rpx;
						display: none;
					}
					.bang{
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #FF8F39;
						display: inline-block;
						margin-left: 14rpx;
					}

				}
				.tiitem:last-child{
					margin-bottom: 0;
				}
				.tactive{
					.zhigou{
						display: none;
					}
					.zhigous{
						display: inline-block;
					}
				}
			}
		}
		
		.tibtn{
			margin: 60rpx 30rpx 80rpx;
			height: 78rpx;
			background: #52443B;
			border-radius: 16rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #FFFFFF;
		}
	}
	.ticontent{
		color: #666;
	}
	
</style>
